<!-- 面试列表 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">面试列表</p>
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
      :czFun="czFun"
    ></dxtable>
  </div>
</template>
<script lang="ts" setup>
import { Options } from "@vicons/ionicons5";
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import {
  dxget,
  dxpost,
  transferTimeYMDHm,
  dialog,
  dxdel,
} from "../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive, render } from "vue";
const databale = ref();
const dqobj = ref({});
const initeer = () => {
  databale.value.initDataExpose();
};

let dataJson = [
  {
    title: "职位名称",
    key: "miansi.zwid",
    width: "",
    type: "select",
    options: [],
    search: true,
    istable: true,
    required: false,
    render: (row) => {
      return row.name;
    },
  },
  // {
  //   title: "试用期价格",
  //   key: "syqjg",
  //   width: "",
  //   search: false,
  //   istable: true,
  //   required: false,
  // },
  // {
  //   title: "薪资待遇",
  //   key: "xzdy",
  //   width: "",
  //   search: false,
  //   istable: true,
  //   required: false,
  // },
  // {
  //   title: "工作地点",
  //   width: "",
  //   search: false,
  //   istable: true,
  //   required: false,
  //   render: (row) => {
  //     return row.sheng + "-" + row.shi;
  //   },
  // },
  {
    title: "投递人姓名",
    key: "miansi.uid",
    type: "select",
    options: [],
    search: true,
    istable: true,
    required: false,
    width: 150,
    render(row) {
      return row.uname;
    },
  },
  {
    title: "投递人电话",
    key: "phone",
    search: false,
    istable: true,
    width: 150,
    required: false,
  },
  {
    title: "面试时间",
    key: "mssj",
    width: 150,
  },
  {
    title: "面试地点",
    key: "msdd",
  },
  {
    title: "备注",
    key: "beizhu",
  },
];

const qx = {
  DeletePermissionID: "23456", //删除
  EditPermissionIdentifier: "23456", // 编辑
  NewPermissionIdentifier: "23456", // 新建
  ViewPermissionID: "jyczhaopingck", // 查看
};
const portUrl = "jyc/miansi/miansi?miansi.luyong=1&b.zpzt=1";

let formJson = reactive([]);
let jjdsfsd = ref(false);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          loading: jjdsfsd.value,
          onClick: async (e) => {
            let statics: any = await dialog("确定录用" + row.uname + "吗？");
            if (statics == 1) {
              jjdsfsd.value = true;
              await dxpost(
                portUrl,
                { id: row.id, luyong: 2, lysj: transferTimeYMDHm() },
                "put"
              );
              await dxpost(
                "jyc/zhaoping/zhaoping",
                { id: row.zwid, zpzt: 2, ypzid: row.uid },
                "put"
              );
              jjdsfsd.value = false;

              try {
                await dxpost("jyc/jycadmin/putongrizhi", {
                  id: row.ui,
                  name: row.name,
                  beizhu: "恭喜您，有企业录用了您",
                  czlx: "录用",
                });
              } catch (e) {}
              initeer();
            }
          },
        },
        "录用"
      ),
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {
            let statics: any = await dialog("是否取消本场面试");
            if (statics == 1) {
              await dxdel(portUrl, { id: row.id });
              await dxpost(
                "jyc/jycadmin/uikdlfds",
                {
                  zwid: row.zwid,
                  uid: row.uid,
                },
                "post"
              );

              try {
                await dxpost("jyc/jycadmin/putongrizhi", {
                  id: row.uid,
                  name: row.name,
                  beizhu: "很抱歉，本场面试已被管理员取消了",
                  czlx: "取消面试",
                });
              } catch (e) {}
              initeer();
            }
          },
        },
        "取消面试"
      ),
    ];
  },
};

const getgetuserList = async () => {
  const { data }: any = await dxget("jyc/api/getuserList");
  dataJson[1].options = [
    {
      label: "全部",
      value: "",
    },
    ...data,
  ];
};
getgetuserList();

const getzhiwei = async () => {
  const { data }: any = await dxget("jyc/api/getzhiwei");
  dataJson[0].options = [
    {
      label: "全部",
      value: "",
    },
    ...data,
  ];
};
getzhiwei();
</script>
<style scoped></style>
